home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / system / ctest259.zip / DHRY.PAS < prev    next >
Pascal/Delphi Source File  |  1992-04-05  |  28KB  |  764 lines

  1. {$A+,B-,D-,E+,F-,G-,I-,L-,N+,O-,R-,S-,V-,X-}
  2. {$M 4096,0,655360}
  3. UNIT Dhry;
  4.  
  5. INTERFACE
  6.  
  7. FUNCTION Dhrystones (Index: DOUBLE): DOUBLE;
  8.  
  9. IMPLEMENTATION
  10.  
  11. USES Time;
  12.  
  13. (*
  14.  ****************************************************************************
  15.  *
  16.  *                   "DHRYSTONE" Benchmark Program
  17.  *                   -----------------------------
  18.  *
  19.  *  Version:    Pascal, Version 2.1
  20.  *
  21.  *  File:       dhry.p
  22.  *
  23.  *  Date:       May 25, 1988
  24.  *
  25.  *  Author:     Reinhold P. Weicker
  26.  *                      Siemens AG, E STE 35
  27.  *                      Postfach 3220
  28.  *                      8520 Erlangen
  29.  *                      Germany (West)
  30.  *                              Phone:  [xxx-49]-9131-7-20330
  31.  *                                      (8-17 Central European Time)
  32.  *                              Usenet: ..!mcvax!unido!estevax!weicker
  33.  *
  34.  *              Original Version (in Ada) published in
  35.  *              "Communications of the ACM" vol. 27., no. 10 (Oct. 1984),
  36.  *              pp. 1013 - 1030, together with the statistics
  37.  *              on which the distribution of statements etc. is based,
  38.  *
  39.  *              This version uses calls to the Pascal runtime library of the
  40.  *              Berkeley UNIX system (4.3 bsd) for time measurement.
  41.  *              For measurements on other systems, these calls need to be
  42.  *              modified.
  43.  *
  44.  *  Collection of Results:
  45.  *              Reinhold Weicker (address see above) and
  46.  *
  47.  *              Rick Richardson
  48.  *              PC Research. Inc.
  49.  *              94 Apple Orchard Drive
  50.  *              Tinton Falls, NJ 07724
  51.  *                      Phone:  (201) 834-1378 (9-17 EST)
  52.  *                      Usenet: ...!seismo!uunet!pcrat!rick
  53.  *
  54.  *      Please send results to Rick Richardson and/or Reinhold Weicker.
  55.  *      Complete information should be given on hardware and software used.
  56.  *      Hardware information includes: Machine type, CPU, type and size
  57.  *      of caches; for microprocessors: clock frequency, memory speed
  58.  *      (number of wait states).
  59.  *      Software information includes: Compiler (and runtime library)
  60.  *      manufacturer and version, compilation switches, OS version.
  61.  *      The Operating System version may give an indication about the
  62.  *      compiler; Dhrystone itself performs no OS calls in the measurement loop.
  63.  *
  64.  *      The complete output generated by the program should be mailed
  65.  *      such that at least some checks for correctness can be made.
  66.  *
  67.  ****************************************************************************
  68.  *
  69.  *  History:    This version Pascal/2.1 has been made for two reasons:
  70.  *
  71.  *              1) There is a need for a common Pascal version of
  72.  *              Dhrystone. Although translation from the published (Ada)
  73.  *              version to Pascal is straightforward in most aspects,
  74.  *              there are cases where it may not be obvious to everyone.
  75.  *              There should be, as far as possible, only one Pascal version
  76.  *              of Dhrystone such that results can be compared without
  77.  *              restrictions. Also, a Pascal version of Dhrystone has not yet
  78.  *              found a network distribution comparable to the C version
  79.  *              (version 1.1) distributed by Rick Richardson.
  80.  *
  81.  *              2) As far as it is possible without changes to the Dhrystone
  82.  *              statistics, optimizing compilers should be prevented from
  83.  *              removing significant statements.
  84.  *
  85.  *              This Pascal version 2.1 has been made consistent with the
  86.  *              C version 2.1; therefore the acknowledgments for the C version
  87.  *              are due for the Pascal version as well: I thank
  88.  *              Rick Richardson (Tinton Falls, NJ), Chaim Benedelac (Nat.
  89.  *              Semi.), David Ditzel (SUN), Earl Killian and John Mashey (MIPS),
  90.  *              Alan Smith and Rafael Saavedra-Barrera (UC at Berkeley)
  91.  *              for their help with comments on earlier versions of the
  92.  *              benchmark.
  93.  *
  94.  *  Changes:    In the initialization part, this version differs
  95.  *              from the Pascal version previously distributed by Reinhold
  96.  *              Weicker, the number of runs through Dhrystone is obtained
  97.  *              interactively from the terminal. Output of the result
  98.  *              has been changed to conform to the C version (2.1).
  99.  *              The changes in the initialization part and in the printing
  100.  *              of the result have no impact on performance measurement
  101.  *              since they are outside the measaurement loop.
  102.  *
  103.  *              Inside the measurement loop, this version follows the
  104.  *              version previously distributed by Reinhold Weicker.
  105.  *              As a correction to the published version, a statement
  106.  *              initializing Array2Glob [8,7] (outside the measurement
  107.  *              loop) has been added. Otherwise, this array element would
  108.  *              have an undefined value.
  109.  *
  110.  *              At several places in the benchmark, code has been added,
  111.  *              but within the measurement loop only in branches that
  112.  *              are not executed. The intention is that optimizing compilers
  113.  *              should be prevented from moving code out of the measurement
  114.  *              loop, or from removing code altogether. Since the statements
  115.  *              that are executed within the measurement loop have NOT been
  116.  *              changed, all numbers defining the "Dhrystone distribution"
  117.  *              (distribution of statements, operand types and locality)
  118.  *              still hold. Except for sophisticated optimizing compilers,
  119.  *              execution times for this version should be the same as
  120.  *              for previous versions.
  121.  *
  122.  *              Since it has proven difficult to subtract the time for the
  123.  *              measurement loop overhead in a correct way, the loop check
  124.  *              has been made a part of the benchmark. This does have
  125.  *              an impact - though a very minor one - on the distribution
  126.  *              statistics which have been updated for this version.
  127.  *
  128.  *              All changes within the measurement loop are described
  129.  *              and discussed in the companion paper "Rationale for
  130.  *              Dhrystone version 2".
  131.  *
  132.  *              Because of the self-imposed limitation that the order and
  133.  *              distribution of the executed statements should not be
  134.  *              changed, there are still cases where optimizing compilers
  135.  *              may not generate code for some statements. To a certain
  136.  *              degree, this is unavoidable for small synthetic benchmarks.
  137.  *              Users of the benchmark are advised to check code listings
  138.  *              whether code is generated for all statements of Dhrystone.
  139.  *
  140.  *              Version 2.1 is identical to version 2.0 distributed via
  141.  *              the UNIX network Usenet in March 1988 except that it corrects
  142.  *              some minor deficiencies that were found by users of version 2.0.
  143.  *              The only change within the measurement loop is that a
  144.  *              non-executed "else" part was added to the "if" statement in
  145.  *              Func3, and a non-executed "else" part removed from Proc3.
  146.  *
  147.  ***************************************************************************
  148.  *
  149.  *  Compilation model and measurement (IMPORTANT):
  150.  *
  151.  *  This program contains the Dhrystone program, including measurement setup,
  152.  *  in one file. The original (Ada) program contained three packages,
  153.  *  - a package with global type definitions,
  154.  *  - Pack_1, containing the main program (Proc_0 in Ada) and procedures
  155.  *            Proc_1, ... , Proc_5,
  156.  *  - Pack_2, containing Proc_6, ... , Proc_8, Func_1, ..., Func_3.
  157.  *  Since ISO/ANSI Standard Pascal provides no means to express separate
  158.  *  compilation (although many Pascal implementations provide such a feature),
  159.  *  it is not possible to formulate a portable Pascal version with the program
  160.  *  in several